package com.zrrd.javaWeb.servlet.teaServlet;

import com.alibaba.fastjson.JSON;
import com.zrrd.javaWeb.bean.Tea;
import com.zrrd.javaWeb.service.TeaService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title QueryTeaAllServlet
 * @description
 * @create 2024/1/22 10:27
 */
@WebServlet("/queryTeaAll")
public class QueryTeaAllServlet extends HttpServlet {
    private TeaService teaService=new TeaService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        List<Tea> list = teaService.queryAll();
        String jsonTea = JSON.toJSONString(list);
        resp.getWriter().write(jsonTea);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
